function funType6(sn: string | null): string{
  if(sn === null){
      return 'null'
  } else {
      return sn
  }
}
// 或者 使用运算符
function funType8(sn: string | null): string{
  return sn || 'null'
}

// 类型断言的方式
interface Bird {
  fly: boolean;
  
  sing: () => {};
}
interface Dog {
  fly: boolean;
  bark: () => {};
}

function trainAnimal(animal: Bird | Dog){
  if(animal.fly){
    (animal as Bird).sing()
  }else {
    (animal as Dog).bark()
  }
}